#! /bin/bash
 
echo "start ..."


# 检查系统是否已安装 Git
if ! [ -x "$(command -v git)" ]; then
  echo 'Git false'
  
  # 根据系统使用不同的包管理器安装 Git
  if [ -x "$(command -v apt-get)" ]; then
    echo 123456 | sudo -S apt-get update
    echo 123456 | sudo -S apt-get install git -y
  elif [ -x "$(command -v yum)" ]; then
    echo 123456 | sudo -S yum install git -y
  else
    echo '无法识别的系统，请手动安装 Git。'
    exit 1
  fi
  
  # 检查 Git 是否安装成功
  if ! [ -x "$(command -v git)" ]; then
    echo 'Git 安装失败，请手动安装 Git。'
    exit 1
  else
    echo 'Git suss'
  fi
else
  echo 'Git installed'
fi


# 删除/home/jetson/Image_acquisition文件夹下除了文件夹pic和文件robot.db的所有文件和文件夹
find /home/jetson/Image_acquisition -mindepth 1 -maxdepth 1 -type f,d ! -name pic ! -name robot.db -exec sudo rm -rf {} \;
 
rm -rf /home/jetson/sy_dcxc
 
git clone https://gitee.com/li-zhenting/sy_dcxc.git
 
echo 123456 | sudo -S mv /home/jetson/sy_dcxc/* /home/jetson/Image_acquisition
echo 123456 | sudo -S mv /home/jetson/sy_dcxc/.git /home/jetson/Image_acquisition
echo 123456 | sudo -S mv /home/jetson/sy_dcxc/.gitignore /home/jetson/Image_acquisition
 
rm -rf /home/jetson/sy_dcxc
 
echo "end ..."
